#!/bin/sh

# Greg Kennedy 2013
# Part of the MisCopter project
# http://code.google.com/p/miscopter

# Installs the MisCopter data from a SimCopter CD

echo "MisCopter data installation script\nGreg Kennedy2013\n"

# Copy command
COPY=cp -R

INPUT_DEFAULT=/media/cdrom
OUTPUT_DEFAULT=/usr/share/games/miscopter

echo "Please enter the mountpoint of your SimCopter CD [$INPUT_DEFAULT]: "
read INPUT
if [ "$INPUT" = "" ]; then
	INPUT = INPUT_DEFAULT
fi

echo "Please enter the install path for MisCopter data [$OUTPUT_DEFAULT]: "
read OUTPUT
if [ "$OUTPUT" = "" ]; then
	OUTPUT = OUTPUT_DEFAULT
fi

TEMP="$(mktemp)"
mkdir -p $TEMP

# retrieve the color palette
./extract_bin $INPUT/SIMCOPTER/geo/sim3d1.max 61 768 $TEMP/cmap.bin
# extract the image sets
./extract_bmp $TEMP/cmap.bin $INPUT/SIMCOPTER/bmp/sim3d.bmp $OUTPUT/data/image/sim3d
./extract_bmp $TEMP/cmap.bin $INPUT/SIMCOPTER/bmp/sky.bmp $OUTPUT/data/image/sky
./extract_bmp $TEMP/cmap.bin $INPUT/SIMCOPTER/bmp/skydark.bmp $OUTPUT/data/image/skydark
# extract all objects
./extract_obj $INPUT/SIMCOPTER/geo/sim3d1.max $OUTPUT/data/model
./extract_obj $INPUT/SIMCOPTER/geo/sim3d2.max $OUTPUT/data/model
./extract_obj $INPUT/SIMCOPTER/geo/sim3d3.max $OUTPUT/data/model
# extract all text

# extract all movies
$COPY $INPUT/SIMCOPTER/smk/* $OUTPUT/data/video
# extract all sounds
$COPY $INPUT/SIMCOPTER/sound/* $OUTPUT/data/audio
